home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 October: Mac OS SDK / Dev.CD Oct 97 SDK1.toast / Development Kits (Disc 1) / QuickDraw GX / Programming Stuff / Sample Code / Typography Samples / Dave’s Fab Samples ƒ / Optical Alignment.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-06-18  |  2.1 KB  |  88 lines  |  [TEXT/KAHL]

  1. /****************************************************************************************************
  2.     6/96 bob    Updated #includes to support changed GX Library names.
  3.     
  4.     ©1990 - 1996  Apple Computer, Inc.
  5.     All rights reserved.
  6. ****************************************************************************************************/
  7. #include <Types.h>
  8. #include <QuickDraw.h>
  9. #include <Fonts.h>
  10. #include <Windows.h>
  11. #include <Menus.h>
  12. #include <SegLoad.h>
  13. #include <Memory.h>
  14. #include <Desk.h>
  15.  
  16. #include <GXGraphics.h>
  17. #include "GraphicsLibraries.h"
  18. #include <GXEnvironment.h>
  19.  
  20. #include <GXTypes.h>
  21. #include <GXLayout.h>
  22. #include "LayoutLibrary.h"
  23.  
  24. #include "SampleInterface.h"
  25.  
  26. short MyStrLen(char *x);
  27. static short MyStrLen(x)
  28. char    *x;
  29.     {
  30.     short c = 0;
  31.     while (*x++) c++;
  32.     return c;
  33.     }    /* MyStrLen */
  34.  
  35. void OpticalAlignment(WindowPtr sampleWindow)
  36.     {
  37.     /* Variables */
  38.     char            *myString = "Oh, NOOO";
  39.     gxLayoutOptions    gxLayoutOptions;
  40.     gxLine            myLine;
  41.     gxPoint            myPoint;
  42.     gxRunControls        gxRunControls;
  43.     gxShape            layout;
  44.     short            len, level = 0;
  45.     gxStyle            myStyle;
  46.     gxViewPort        aViewPort;
  47.     
  48.     /* Initialization */
  49.     
  50.     myPoint.x = ff(20);
  51.     myPoint.y = ff(50);
  52.     
  53.     aViewPort = GXNewWindowViewPort(sampleWindow);
  54.     SetDefaultViewPort(aViewPort);
  55.     
  56.     len = MyStrLen(myString);
  57.     InitializeRunControls(&gxRunControls);
  58.     InitializeLayoutOptions(&gxLayoutOptions);
  59.     gxLayoutOptions.width = ff(300);
  60.     gxLayoutOptions.just = fract1;
  61.  
  62.     myLine.first.x = myLine.last.x = myPoint.x;
  63.     myLine.first.y = 0;
  64.     myLine.last.y = ff(1000);
  65.     GXDrawLine(&myLine);
  66.     
  67.     myLine.first.x = myLine.last.x = myPoint.x + gxLayoutOptions.width;
  68.     GXDrawLine(&myLine);
  69.     
  70.     myStyle = NewLayoutStyle((char *) "\pHoefler Text", ff(50), 0, nil, nil, 0, nil);
  71.     
  72.     layout = GXNewLayout(
  73.         1, &len, (void *) &myString,
  74.         1, &len, &myStyle,
  75.         1, &len, &level,
  76.         &gxLayoutOptions, &myPoint);
  77.     GXDrawShape(layout);
  78.     
  79.     gxRunControls.flags = gxNoOpticalAlignment;
  80.     GXSetStyleRunControls(myStyle, &gxRunControls);
  81.     GXMoveShape(layout, 0, ff(75));
  82.     GXDrawShape(layout);
  83.     
  84.     GXDisposeShape(layout);
  85.     GXDisposeStyle(myStyle);
  86.     GXDisposeViewPort(aViewPort);
  87.     }    /* main */
  88.